﻿@model Forum
@{
    var _options = ForumContext.ModeratorOptions(Model.ForumId);

    var _forums = ForumRepo.ListAll().Select(f => new SelectListItem
      {
          Value = f.ForumId.ToString(),
          Text = string.Format("{0}{1}", ForumContext.Padding(f.Level), f.ForumName),
          Selected = (Model.ForumId == f.ForumId)
      });
    
}
<div class="site-block white-t">
    <div class="header">
        <span class="icon"></span>
        @ForumContext.GetText(LanguageSection.TOPICS, "MODERATION_TOOL")
    </div>
    <form action="@ForumContext.GetAbsoluteUrl(ForumUrls.COMMAND)" id="_mod">
    
    
        <div class="site-block-content">
            <input type="checkbox" onclick="$.MvcForum.toggleCheckbox(this.checked)" />
            @Html.AntiForgeryToken()
            @Html.Hidden("f", Model.ForumId)
            @Html.AntiModelInjection("f", Model.ForumId)
            @Html.Hidden("Ids", "")
            @Html.DropDownList("act", _options, "--", new { @class = "select {validate:{required:1}}" })
            <span id="_move_panel" class="hidden">
                @Html.DropDownList("moveTo", _forums, new { @class = "select" }) |
                <input type="checkbox" id="enabledRedirect" name="enabledRedirect" value="true" /><label
                    for="enabledRedirect">Enabled Redirect</label>
                | </span><span id="_expireDate" class="hidden">
                    <label>
                        @ForumContext.GetText(LanguageSection.MODERATOR_TOOL, "Expires")
                    </label>
                    @Html.TextBox("expires", "", new { @class = "input datepicker {datetimeFormat:'O/D/Y H:M a',minDatetime:new Date()}", style = "width: 140px" })
                </span>
            @Html.Link("javascript://", ForumContext.GetText(LanguageSection.TOPICS, "GO"), new { @class = "ui-button", @onclick = "$('#_mod').submit()" })
        </div>
   </form>
</div>
@using (Html.BeginScriptBlock())
{
    <script type="text/javascript">

        $(function () {
            $('#_mod').unbind('.mvcforum').bind('submit.mvcforum', function (e) {
                e.preventDefault();
                var _f = $(this);
                var _items = $.MvcForum.getSelectedItems();
                if (_items.length > 0) {
                    $('#Ids').val(_items.join(','));
                    $.Ajax.submit(_f);
                    
                }
                else {
                    $.MvcForum.alert('@ForumContext.GetText(LanguageSection.MESSAGES, "MUST_SELECT_ITEM")');
                }
                return false;

            });

            $('#act').bind('change', function () {
                var _val = $(this).val();
                if (_val == '@((int)ModerateCommandType.Move)') {
                    $('#_move_panel').fadeIn();
                }
                else {
                    $('#_move_panel').hide();
                };

                if (_val == '@((int)ModerateCommandType.Pin)' || _val == '@((int)ModerateCommandType.Move)') {
                    $('#_expireDate').fadeIn();
                }
                else {
                    $('#_expireDate').hide();
                };

            });

        });
    
    </script>
}
